home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14928 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: fido.asd.sgi.com!news
  2. From: austern@isolde.mti.sgi.com (Matt Austern)
  3. Newsgroups: comp.object,comp.lang.c++,comp.lang.java
  4. Subject: Re: Java: What's the Big Deal?  (GC)
  5. Date: 02 Apr 1996 19:41:13 GMT
  6. Organization: SGI
  7. Message-ID: <AUSTERN.96Apr2114113@isolde.mti.sgi.com>
  8. References: <4jk4ee$7ri@newsbf02.news.aol.com> <1996Apr1.155416.12816@schbbs.mot.com>
  9.     <MARKT.96Apr1200203@atlas.harlqn.co.uk>
  10. Reply-To: austern@mti.sgi.com
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. In-reply-to: markt@harlqn.co.uk's message of 01 Apr 96 20:02:03 GMT
  13.  
  14. In article <MARKT.96Apr1200203@atlas.harlqn.co.uk> markt@harlqn.co.uk (Mark Tillotson) writes:
  15.  
  16. > > With Java's array, memory will be smashed into millions of small
  17. > > pieces. Here is a brief comparison:
  18. > <array of struct of 3 floats example omitted>
  19. > On many machines one load instruction is cheaper than multiplying an
  20. > index by 3, so Java's approach is actually faster (other things being
  21. > equal)... 
  22.  
  23. Until you think about locality (which is a very big deal: with today's
  24. CPUs, high cache hit rates are critical), or the effect of memory
  25. fragmentation, or the time required for many tiny allocations, or the
  26. space overhead of having lots of tiny memory blocks each with its own
  27. control header.
  28.  
  29. Note that this isn't an argument against GC: it's an argument against
  30. writing programs that do many separate tiny allocations.  This is true
  31. irespective of whether you're using GC or manual deallocation.  It's
  32. also old news: lisp programmers have known for decades that your
  33. programs will be faster if you avoid excessive consing.
  34.  
  35. Since this is crossposted to comp.land.c++, I'll note that C++ allows
  36. a very simple optimization: if you need many small heap-allocated
  37. objects of some type, you can redefine operator new for that type.
  38. This is useful for things like linked list nodes, and in cases like
  39. that it can yield enormous performance improvements.
  40. -- 
  41. Matt Austern
  42. SGI: MTI Compilers Group
  43. austern@isolde.mti.sgi.com
  44.